home *** CD-ROM | disk | FTP | other *** search
- property _me, pTable, pSuperTable, pTableChannel, pTableLoc, pVSlider, pUpButton, pDownButton, pVisRect
- global gGraph
-
- on new me, tableName, castName, tableChannel, tableLoc, vSlider, upButton, downButton, descendant
- if objectp(descendant) then
- _me = descendant
- else
- _me = me
- end if
- pTable = member(tableName, castName)
- pTableChannel = tableChannel
- pTableLoc = tableLoc
- pVSlider = vSlider
- pUpButton = upButton
- pDownButton = downButton
- return me
- end
-
- on setSuperTable me, superTable
- pSuperTable = superTable
- return me
- end
-
- on init me, cellWidth, cellHeight, numRows, numCols, data, visRect
- sizeAllCells(pTable, cellWidth, cellHeight)
- pTable.rowCount = numRows
- pTable.columnCount = numCols
- pTable.borderSize = 1
- pTable.defaultMacTextFont = "helvetica"
- pTable.defaultWinTextFont = "arial"
- pTable.defaultTextSize = 9
- pTable.defaultHAlign = "center"
- pTable.defaultVAlign = "center"
- pTable.tableData = data
- pVisRect = visRect
- return me
- end
-
- on condemn me
- _me = 0
- return me
- end
-
- on Inscope me
- puppetSprite(pTableChannel, 1)
- return me
- end
-
- on outScope me
- puppetSprite(pTableChannel, 0)
- return me
- end
-
- on showMe me
- set the loc of sprite pTableChannel to pTableLoc
- updateStage()
- return me
- end
-
- on hideMe me
- set the loc of sprite pTableChannel to point(-9999, -9999)
- updateStage()
- return me
- end
-
- on trackMouse me
- return me
- end
-
- on doRollover me
- return me
- end
-
- on scrollUp me
- oldTop = pVisRect.top
- pVisRect.top = pVisRect.top + (getSetting(pVSlider) - oldTop)
- pVisRect.bottom = pVisRect.bottom + (getSetting(pVSlider) - oldTop)
- sprite(pTableChannel).vScroll = (getRowHeight(member(pTable), 1) - 1) * (getSetting(pVSlider) - 1)
- return me
- end
-
- on scrollDown me
- oldTop = pVisRect.top
- pVisRect.top = pVisRect.top + (getSetting(pVSlider) - oldTop)
- pVisRect.bottom = pVisRect.bottom + (getSetting(pVSlider) - oldTop)
- sprite(pTableChannel).vScroll = (getRowHeight(member(pTable), 1) - 1) * (getSetting(pVSlider) - 1)
- return me
- end
-
- on getTopRow me
- return pVisRect.top
- end
-
- on getLeftColumn me
- return pVisRect.left
- end
-
- on getBottomRow me
- return pVisRect.bottom
- end
-
- on getRightColumn me
- return pVisRect.right
- end
-
- on atTop me
- return pVisRect.top = 1
- end
-
- on atBottom me
- return pVisRect.bottom = pTable.rowCount
- end
-
- on getNumColumns me
- return pTable.columnCount
- end
-
- on getNumRows me
- return pTable.rowCount
- end
-
- on isAbove me, v
- return v <= the top of sprite pTableChannel
- end
-
- on isBelow me, v
- return v > the bottom of sprite pTableChannel
- end
-
- on isLeftOf me, h
- return h <= the left of sprite pTableChannel
- end
-
- on isRightOf me, h
- return h > the right of sprite pTableChannel
- end
-
- on getMouseCell me, h, v
- if v <= (the top of sprite pTableChannel + 5) then
- v = the top of sprite pTableChannel + 5
- else
- if v > (the bottom of sprite pTableChannel - 5) then
- v = the bottom of sprite pTableChannel - 5
- end if
- end if
- if h <= (the left of sprite pTableChannel + 5) then
- h = the left of sprite pTableChannel + 5
- else
- if h > (the right of sprite pTableChannel - 5) then
- h = the right of sprite pTableChannel - 5
- end if
- end if
- return cellToPoint(me._me, pointToCell(sprite(pTableChannel), point(h, v)))
- end
-
- on getVisRect me, theRect
- R = rect(0, 0, 0, 0)
- if not ((theRect.left > pVisRect.right) or (theRect.top > pVisRect.bottom) or (theRect.right < pVisRect.left) or (theRect.bottom < pVisRect.top)) then
- R.left = max(theRect.left, pVisRect.left)
- R.top = max(theRect.top, pVisRect.top)
- R.right = min(theRect.right, pVisRect.right)
- R.bottom = min(theRect.bottom, pVisRect.bottom)
- end if
- if R <> rect(0, 0, 0, 0) then
- r1 = getCellRect(sprite(pTableChannel), point(getAt(R, 1), getAt(R, 2)))
- r2 = getCellRect(sprite(pTableChannel), point(getAt(R, 3), getAt(R, 4)))
- if not voidp(r1) and not voidp(r2) then
- R = rect(r1.left, r1.top, r2.right, r2.bottom)
- else
- R = rect(0, 0, 0, 0)
- end if
- end if
- return R
- end
-
- on cellToPoint me, theCell
- if (theCell mod pTable.columnCount) = 0 then
- return point(pTable.columnCount, theCell / pTable.columnCount)
- else
- return point(theCell mod pTable.columnCount, (theCell / pTable.columnCount) + 1)
- end if
- end
-
- on getData me
- return member(pTable).tableData
- end
-
- on setData me, data
- member(pTable).tableData = data
- return me
- end
-
- on getCellRect me, theCell
- return getCellRect(sprite(pTableChannel), theCell)
- end
-
- on isCellVisible me, theCellRect
- return intersect(the rect of sprite pTableChannel, theCellRect) <> rect(0, 0, 0, 0)
- end
-
- on isEditCellVisible me, theCell
- h = getAt(theCell, 1)
- v = getAt(theCell, 2)
- return not ((h > pVisRect.right) or (v > pVisRect.bottom) or (h < pVisRect.left) or (v < pVisRect.top))
- end
-
- on getCellContents me, theCell
- cellRef = (pTable.columnCount * (getAt(theCell, 2) - 1)) + getAt(theCell, 1)
- return getAt(member(pTable).tableData, cellRef)
- end
-
- on setCellContents me, theCell, theContents
- t = duplicate(member(pTable).tableData)
- cellRef = (pTable.columnCount * (getAt(theCell, 2) - 1)) + getAt(theCell, 1)
- oldContents = getAt(member(pTable).tableData, cellRef)
- setAt(t, cellRef, theContents)
- member(pTable).tableData = t
- return me
- end
-
- on getSelectedData me, theRect
- data = duplicate(member(pTable).tableData)
- selectedData = []
- repeat with i = theRect.top to theRect.bottom
- repeat with j = theRect.left to theRect.right
- append(selectedData, getAt(data, ((i - 1) * pTable.columnCount) + j))
- end repeat
- end repeat
- return selectedData
- end
-
- on cutSelectedData me, theRect
- data = duplicate(member(pTable).tableData)
- selectedData = []
- repeat with i = theRect.top to theRect.bottom
- repeat with j = theRect.left to theRect.right
- append(selectedData, getAt(data, ((i - 1) * pTable.columnCount) + j))
- setAt(data, ((i - 1) * pTable.columnCount) + j, EMPTY)
- end repeat
- end repeat
- member(pTable).tableData = data
- return selectedData
- end
-
- on setSelectedData me, theRect, data
- numCols = theRect.right - theRect.left + 1
- if theRect.right > pTable.columnCount then
- c = pTable.columnCount
- else
- c = theRect.right
- end if
- numRows = theRect.bottom - theRect.top + 1
- if theRect.bottom > pTable.rowCount then
- R = pTable.rowCount
- else
- R = theRect.bottom
- end if
- newData = duplicate(member(pTable).tableData)
- repeat with i = theRect.left to c
- repeat with j = theRect.top to R
- locInTableList = ((j - 1) * pTable.columnCount) + i
- locInPasteList = ((j - theRect.top) * numCols) + (i - theRect.left + 1)
- setAt(newData, locInTableList, getAt(data, locInPasteList))
- end repeat
- end repeat
- member(pTable).tableData = newData
- return me
- end
-